function [xbeta expxbeta logLik y] = ComputePredictiveLogLikelihood(modelFileName,dataFileName)

model = dlmread(modelFileName);
model(:,2) = [];
model = sortrows(model,1);
inds = model(:,1);
beta = zeros(max(inds),1);

beta(inds) = model(:,2);

fp = fopen(dataFileName,'r');
data = textscan(fp,'%s','Delimiter','\n','BufSize',20000);
data = data{1};
fclose(fp);

n = length(data);
p = size(beta);
xbeta = zeros(n,1);
expxbeta = zeros(n,1);
logLik = zeros(n,1);
y = zeros(n,1);

for i = 1:n,
    if(mod(i,10000) == 0)
        fprintf('i = %d\n',i);
    end
    x = zeros(p,1);
    line = data{i};
    colon = find(line == ':');
    y(i) = str2num(line(colon(1)+1));
    for j = 2:length(colon),
        space = find(line(colon(j-1):colon(j)) == ' ');
        if(length(space) > 1)
            fprintf('Error!\n');
            return;
        end
        space = colon(j-1) + space - 1;
        num = str2num(line(space+1:colon(j)-1));
        value = str2num(line(colon(j)+1));
        x(num) = value;
    end
    xbeta(i) = x'*beta;
    expxbeta(i) = exp(xbeta(i));
    if(i > 1)
        expxbeta(i) = expxbeta(i) + expxbeta(i-1);
    end
    logLik(i) = y(i) * xbeta(i);
    if(i > 1)
        logLik(i) = logLik(i) - y(i) * log(expxbeta(i));
    end
end

return